<?php

namespace App\Models;

use App\Models\Traits\Filters;
use Illuminate\Database\Eloquent\Model;

class RentClothOrder extends Model
{
    use Filters;
    public function setImgUrlAttribute($ImgUrl)
    {
        if (is_array($ImgUrl)) {
            $this->attributes['img_url'] = json_encode($ImgUrl);
        }
    }

    public function getImgUrlAttribute($ImgUrl)
    {
        return json_decode($ImgUrl, true);
    }

    public function user()
    {
        return $this->hasOne(User::class, 'id', 'user_id');
    }

    public function rentcloth()
    {
        return $this->hasOne(RentCloth::class, 'id', 'rent_id');
    }

    public function commodity()
    {
        return $this->hasOne(Commodity::class, 'id', 'com_id');
    }

    public function commodityattr()
    {
        return $this->hasOne(CommodityAttr::class, 'id', 'com_attr_id');
    }

    public function brand()
    {
        return $this->hasOne(Brand::class, 'id', 'brand_id');
    }

    public function orderpraise()
    {
        return $this->hasOne(OrderPraise::class, 'order_id', 'id');
    }

    public function rentclothdetail()
    {
        return $this->hasOne(RentClothDetail::class, 'rent_id', 'rent_id');
    }

    public function shop()
    {
        return $this->hasOne(Shop::class, 'id', 'shop_id');
    }

}
